
#include <stdio.h>
#include <stdlib.h>

#ifdef __cplusplus
extern "C" {
#endif
void *jj01_malloc(unsigned int num_bytes,const char*fun ,int line);
void jj01_free(void * ptr,const char*fun ,int line);
void *jj01_realloc(void *mem_address, unsigned int newsize,const char*fun ,int line);
void *jj01_calloc(size_t n, size_t size,const char*fun ,int line);

#ifdef __cplusplus
}
#endif

#define malloc(x)  jj01_malloc((x),__FUNCTION__,__LINE__)
#define realloc(a,b)  jj01_realloc((a),(b),__FUNCTION__,__LINE__)
#define calloc(a,b)  jj01_calloc((a),(b),__FUNCTION__,__LINE__)
#define free(x)  jj01_free((x),__FUNCTION__,__LINE__)


void *jj01_malloc(unsigned int num_bytes,const char*fun ,int line)
{
	void * ret = malloc(num_bytes);
	fprintf(stderr,"[%s,%d]malloc %u %x",fun,line,num_bytes,(long)ret);
	return ret;
}
void *jj01_realloc(void *mem_address, unsigned int newsize,const char*fun ,int line)
{
	void * ret = realloc(mem_address,newsize);
	fprintf(stderr,"[%s,%d]realloc %u %x",fun,line,newsize,(long)ret);
	return ret;
}
void *jj01_calloc(size_t n, size_t size,const char*fun ,int line)
{
	void * ret = calloc(n,size);
	fprintf(stderr,"[%s,%d]calloc %u %x",fun,line,n*size,(long)ret);
	return ret;
}
void jj01_free(void * ptr,const char*fun ,int line)
{
	fprintf(stderr,"[%s,%d]free %x",fun,line,(long)ptr);
	free(ptr);
}
